package com.csii.branch.activity.controller;

import com.csii.core.api.Result;
import com.csii.file.controller.FileController;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/strengthenActivity")
@Api(tags = "增强流程")
public class StrengthenActivityController {

    @Autowired
    private FileController fileController;

    @Value(value="${localServerUrl}")
    private String localServerUrl;

    /**
     * 流程表单上传接口
     * @param request
     * @param response
     * @return
     */
    @PostMapping(value = "/form/upload")
    public Map<String,Object> upload(HttpServletRequest request, HttpServletResponse response) {
        Result<?> upload = fileController.upload(request, response);
        String message = upload.getMessage();
        Map<String,Object> result = new HashMap<>();
        result.put("code",0);
        Map<String, Object> data = new HashMap<>();
        data.put("url",localServerUrl+"/sys/common/static/"+message);
        result.put("data",data);
        return result;
    }
}
